<template>
	<div class="app-container">
		<el-collapse v-model="activeName" accordion  v-if="testList.length > 0">
			<el-collapse-item v-for="(item, index) in testList" :key="index" :name="index">
				<template slot="title">
					{{indexMethod(index)}}.{{ item.result }}<el-tag :type="item.type == 0 ? 'danger': 'warning'" effect="dark">{{item.type == 0 ? '结肠': '痔疮'}}</el-tag>
				</template>
				<div v-for="(res, i) in JSON.parse(item.questionnaire)">
					<span style="margin-left: 40px;">
						{{i+1}}.{{res.question}}&nbsp;&nbsp;&nbsp;---&nbsp;&nbsp;&nbsp;{{res.answer}}
					</span>
				</div>
			</el-collapse-item>
		</el-collapse>
		<el-empty :image-size="200" v-else></el-empty>
		<pagination
			v-show="total>0"
			:total="total"
			:page.sync="queryParams.pageNum"
			:limit.sync="queryParams.pageSize"
			@pagination="getList"
		/>
	</div>
</template>

<script>
import { listHealthTest } from '@/api/healthy/healthTest'

export default {
	data() {
		return {
			activeName: 0,
			queryParams: {
				pageNum: 1,
				pageSize: 10,
				userId: undefined
			},
			testList: [],
			total: 0
		};
	},
	mounted() {
		console.log(this.$route)
		this.queryParams.userId = this.$route.query.userId;
		this.getList();
	},
	methods: {
		getList() {
			listHealthTest(this.queryParams).then(res => {
				this.testList = res.rows;
				this.total = res.total;
			})
		},
		indexMethod(index) {
			return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
		}
	}
}
</script>

<style lang="scss" scoped>

</style>
